<?php

/*
	Class: Commerce_AdminController

	About: Author
		Rich Joslin

	About: License
		<http://communit.as/docs/license>
*/
class Commerce_AdminController extends Cts_Controller_Action_Admin {

	/*
		Function: init
	*/
	function init() {
		parent::init();
	}

	/*
		Function: caching
	*/
	function cachingAction() {
		if ($this->getRequest()->isPost() && $this->getRequest()->has('cache_action')) {
			$cache_instance = new Commerce_Cache();
			$this->cache = $cache_instance->factory;
			
			if( $this->getRequest()->cache_action == 'all' ){
				$this->cache->clean(Zend_Cache::CLEANING_MODE_ALL);
			} else {
				$tags = explode(',', $this->getRequest()->cache_action);
				foreach( $tags as $tag ){
					Cts_Log::report("Cache Clean (via admin) :: {$tag}", NULL, Zend_Log::INFO);
					$this->cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($tag));
				}
			}
			
			$this->view->success = "Successfully cleaned the server cache.";
		}
	}

}
